{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 距离\n",
    " 首先是距离的定义，如何判断两个样本之间的距离度量。<br>\n",
    " 为了理解，我们使用欧式距离作为我们的距离衡量标准，但是实际情况下，每个属性的影响不同，应该定制的去设置距离衡量办法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "def distance(a, b):\n",
    "    a = np.array(a)\n",
    "    b = np.array(b)\n",
    "    assert a.shape == b.shape\n",
    "    diff = a - b\n",
    "    return np.sqrt(np.sum(diff * diff))\n",
    "\n",
    "distance(np.array([[7],[6]]), np.array([[4],[2]]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# K-means\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "首先，`K-mean`是属于无监督学习的，大概步骤如下\n",
    "1. 输入样本数据，指定分类数$k$\n",
    "2. 随机选取$k$个点，作为每个类别的中心点\n",
    "3. 遍历每个数据，把它归为距离最近的中心点的类型\n",
    "4. 计算每个簇，重新定义中心点\n",
    "5. 如果中心点的误差低于指定阈值，或者达到指定迭代次数，返回结果，否则重复3~5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 正态样本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAO1klEQVR4nO3df6hk513H8c/nbrYkk0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jxTGMLkZdUT8g6RvFF1HniLixYh4avz625LOSLpuT7P3S/rL2PGkpKttX7vkUg8sYx9LbTw2r4zfHh7/7L07X/ZxzNLHUrN9VNL7JN2/T5PCxzC5oM7otvGfYo/Y/rGii5mH7bqkm7UzU7nYdZK+dtH7cypp0F2ij1LJx3L8J/Mzks5LejwiVm4cM/RRKvc4flzSb0l6Y5/zhY9hGYP6Ke08E3+jpD+R9DcF13Ngtt8u6XOSPhwR39p7esKvlG4mM6WPpR/LiHg9Im6SdFTSLbZv2NOk9OOYoY+lHUfbd0s6HxFbl2o24dhSx7B0QR0R39r9UywiPi/psO0jBZc1M9uHtRNgvYh4aEKTc5Kuv+j9UUkvLKO2RZnWx1UZS0mKiG9KekLSu/ecKv047tqvjyUfx9sl3WP7rKTPSLrD9qf2tCl8DEsX1LZ/wLbHr2/RTh/+q9iqZjOu/xOSzkTEH+7T7G8l/cL4jvOtkl6OiBeXVuScsvSx7GNpu2r76vHrKyTdJen5Pc3KPo5T+1jmcYyIj0TE0YioSzoh6QsRce+eZoWP4WXL/M+ysP2Adu4iH7F9TtLvaucGhiLizyR9QNKv2H5N0v9KOhHjW7Mlcrukn5f05fG1P0n6HUmb0oV+fl47d5u/Imkk6YMF1DmPLH0s+1heK+mTtg9pJ5w+GxEnbf+ytDLjmKWPZR/Ht0htDHmEHAASV7pLHwCwbghqAEgcQQ0AiSOoASBxBDUAJI6gBoDEEdQAkLj/B8cv9NpYeKwoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from numpy.linalg import cholesky\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "def sample(mu, sigma, count):\n",
    "    R = cholesky(sigma)\n",
    "    dim = len(mu)\n",
    "    return np.dot(np.random.randn(count, dim), R) + mu\n",
    "\n",
    "def scatter(_point,color='black'):\n",
    "    _point = np.array(_point)\n",
    "    if _point.shape[0] > 0:\n",
    "        plt.scatter(_point[:,0], _point[:,1], color=color)\n",
    "    \n",
    "\n",
    "data = sample([3, 7], [[2, 0], [0, 5]], 10)\n",
    "scatter(data)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 样本生成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO2dfWwd13nmn5e0tPW1E9uiZEONy8sGKzgt7NiOiKzbFIs0ioPEdWMjgLtZ3BiEkYKI20XlokWqLf9IXYDYbFo0EbCbBkSaQA3vNvW6Tu26bmBDWy+aYpGAypeSyoaAhGQ+FEui/BFXQv3Bd/+YGelyOGfufJyZOWfm+QEXlxzeO/NeUnruuc/7cURVQQghxD8mmg6AEEJIMSjghBDiKRRwQgjxFAo4IYR4CgWcEEI85bI6L7Z7926dmZmp85KEEOI9x44dO6uqe+LHaxXwmZkZrKys1HlJQgjxHhFZSzpOC4UQQjyFAk4IIZ5CASeEEE+hgBNCiKdQwAkhxFMo4IQQ4ikUcEII8RQKOCGEeAoFnLSC4RCYmQEmJoL74bDpiAipnlo7MQmpguEQmJ8Hzp8Pvl9bC74HgMGgubgIqRovVuBDADMIgp0JvyfN4OLfYmHhknhHnD8fHCekzTgv4EMA8wDWAGh4Pw83hKNOXBBOV/8W6+v5jhPSFpwX8AUAscUVzofHu4Irwunq32J6Ot9x0jzMWdjBeQE3LaK6tLhyRThd/VssLgK93tZjvV5wnLhHlLNYWwNUL+UsKOL5cV7ATYuoLi2uXBFOV/8WgwGwtAT0+4BIcL+0xASmq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/DnqnorgH+F4x/tRWQngPcD+N9Nx5JE6G3fBeDnAfwsgCtE5EPNRpUfCjgAEdmBQLyHqvpIePg5Edkb/nwvglWvE6jqCwCeBvBeuBfnOwC8X0RWAXwRwLtEZBnuxQkAUNUfh/enEXi1b4d7sf4QwA/DT1wA8DACQXctzlHeB+Drqvpc+L1rsb4bwPdV9YyqvgrgEQC/DPfiTKXzAi4iAuAvAJxQ1T8b+dFjAObCr+cQeOONISJ7ROTq8OvLEfwDfAaOxamq/1VVr1fVGQQfof+Pqn4IjsUJACJyhYi8IfoagQf6HTgWq6r+BMAPROSG8NABAP8Cx+KM8Z9xyT4B3It1HcBtItILNeAAgsSwa3Gm0vlOTBH5FQD/BOA4Lnm2f4jAB38IwDSCP/Y9qnqukSABiMhbARxBkC2fAPCQqv6xiEy5FOcoIvJOAL+vqne6GKeIvBnBqhsIbIr/paqLjsZ6C4DPAtgJ4HsA7kP47wAOxQkAItJDkCB8s6q+GB5z8Xf6IID/hKAS7RsAfhPAlXAszjQ6L+CEEOIrnbdQCCHEVyjghBDiKRRwQgjxFAo4IYR4CgWcEEI8hQJOCCGeQgEnhBBP+f9FELBAxXoYuwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sigma = [[40, 0], [0, 40]]\n",
    "count = 50\n",
    "a_mu = [30, 30]\n",
    "b_mu = [30, 70]\n",
    "c_mu = [70, 30]\n",
    "d_mu = [70, 70]\n",
    "sample_a = sample(a_mu, sigma, count)\n",
    "sample_b = sample(b_mu, sigma, count)\n",
    "sample_c = sample(c_mu, sigma, count)\n",
    "sample_d = sample(d_mu, sigma, count)\n",
    "scatter(sample_a, color='red')\n",
    "scatter(sample_b, color='cyan')\n",
    "scatter(sample_c, color='green')\n",
    "scatter(sample_d, color='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAekElEQVR4nO3dbYxkWV3H8e+/e7qBmoUwU6467tLVmGzE1UR0Ozz4FMJKRCQub0jWNHFeYDqpaAQ00SH9whDTERZj3Bdi0gFktEoIQcNucCNuBhIiiWKvGLLLMs4q3c3K4iKwijaBxTm+6KqZ6ur7cO5T3Yfz+ySV7r5ddevUvfec/3m6p8w5h4iIhGep7gSIiEg9FABERAKlACAiEigFABGRQCkAiIgESgFARCRQqQHAzN5vZk+b2aMz286b2cNmdm3y89zM/95uZk+Y2VUz+/mqEi4iIsX4tAA+ALx2btsl4Ipz7g7gyuRvzOxO4F7gRyaveY+ZLZeWWhERKU1qAHDOfQr4+tzme4DLk98vA2+Y2f4h59y3nXNfBJ4AXlZSWkVEpERncr7u+5xzTwE4554ys++dbL8N+PuZ5z052XaKmW0BWwBnz5696yUveUnOpIiIhOmRRx75T+fcrXlfnzcAxLGIbZFrTTjndoFdgI2NDbe3t1dyUkREus3MDoq8Pu8soP8wswuTBFwAnp5sfxJ40czzbge+nD95IiJSlbwB4EHg4uT3i8ADM9vvNbPnmNmLgTuAzxRLooiIVCG1C8jMPgi8CvgeM3sS+F3gncCHzezNwCHwRgDn3GNm9mHg88B3gV9zzv1fRWkXEZECUgOAc+6XY/51d8zzd4CdIokSEZHq6U5gEZFAKQCIiARKAUBEJFAKACIigVIAEBEJlAKAiEigFABERAKlACAiEigFABGRQCkAiIgESgFARCRQCgAiIoFSABARCZQCgIhIoBQAREQCpQAgIhIoBQARkUApAIiIBEoBQEQkUAoAIiKBUgAQEQmUAoCISKAUAEREAqUAICISKAUAEZFAKQCIiARK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sEbwEen/k71OMAcD/wN865lwA/xvFxCep4mNltwG8AG865H+V4Qsm9hHUcPgC8dm5b5OeflB33Aj8yec17JmVsrLpbAEEvGeGce8o590+T37/JcSa/jeNjcHnytMvAG+pJ4eKY2e3ALwLvndkc3HEAMLMXAD8LvA/AOfcd59wzhHk8zgDPM7MzQI/j+4mCOQ7OuU8BX5/bHPf57wE+5Jz7tnPui8ATHJexseoOAFFLRtxWU1pqZWbrwI8D/wB8n3PuKTgOEsD31peyhfkj4LeB6zPbQjwOAD8IfBX400mX2HvN7CyBHQ/n3L8DfwAcAk8B/+Wc+1sCOw4R4j5/5vK07gCQumRECMzsFuAvgbc65/677vQsmpm9HnjaOfdI3WlpiDPATwB/4pz7ceB/6XY3R6RJ3/Y9wIuBHwDOmtmb6k1Vo2UuT+sOAMEvGWFmKxwX/mPn3F9NNv+HmV2Y/P8C8HRd6VuQnwJ+ycz2Oe4GfLWZjQjvOEw9CTzpnPuHyd8f4TgghHY8fg74onPuq865Z4G/An6S8I7DvLjPn7k8rTsABL1khJkZx/28jzvn/nDmXw8CFye/XwQeWHTaFsk593bn3O3OuXWOr4FPOOfeRGDHYco59xXgS2Y2XenxbuDzhHc8DoFXmFlvklfu5nicLLTjMC/u8z8I3GtmzzGzFwN3AJ9J3JNzrtYH8DrgX4B/BbbrTs+CP/tPc9xE+xzwz5PH64A+x6P71yY/z9ed1gUek1cBH5v8HvJxeCmwN7k2PgqcC/F4AO8AvgA8Cvw58JyQjgPwQY7HP57luIb/5qTPD2xPytKrwC+k7V9LQYiIBKruLiAREamJAoCISKAUAEREAqUAICISKAUAEZFAKQCIiARKAUBEJFD/D+DrPRNju4b2AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.xlim(0, 100)\n",
    "plt.ylim(0, 100)\n",
    "data = np.r_[sample_a, sample_b, sample_c, sample_d]\n",
    "scatter(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEICAYAAABWJCMKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3df4zkd33f8ed793Yhc7bL3WDoxWZmaWKFmqiE+BpIS4sVhwZoVKNEqE4X5aomXWmUqk5SKT26akuUbgtO28SqSpQVEC6ZKYQ4BFvUSuJeMChIha5DYtnYl3PC7vqCwQZsYliX2L1P/5jv3M3Ozff39zvfH5/XQxrt7ndnvvOZ7/f7+bw/P79jzjlERMQ/S1UnQEREqqEAICLiKQUAERFPKQCIiHhKAUBExFMKACIinlIAkNYws4fN7Oaq0yHSFAoA0hrOuVc75+4HMLN3mdmw4iRdYma3mNmjZnZgZp8ws37VaRJRABCZw8yOFLivlwIfBf4tcBzYAX6zqP2LZKUAIK1hZrtm9oNm9mbg3wD/2My+YWZ/Evz/r5nZ+83sCTP7CzP7D2a2HPzvn5rZp83sl8zsa8C7zOw7zeyTZvZ1M/uKmWUttH8EeNg591vOuf8LvAt4jZm9Kv+nFslOAUBaxzn3u8B/BH7TOXeVc+41wb/OAC8A3wm8FvgHwE9OvfR1wJ8DLwO2gF8Afh84BlwP/Lew9zSzB83sn4T8+9XAn0yl75vAnwXbRSpTWDNXpM7M7OXAW4CXOOeeA75pZr8EbAC/Gjzti865SSH/gpk9D/SBb3fOXQD+MGz/zrm/FfH2VwFPzWz7OnB1+k8iUhy1AMQXfWAFeMLMnjGzZxgX/C+bes7jM6/5OcCAzwYzjP5Zxvf+BnDNzLZrgGcz7k+kEGoBSFvN3ub2ceBbwEudcy8keY1z7kvAPwcwszcA/8vMPuWceyxlWh4GTk3+MLOjwHcE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H1mdhTPjodz7i+A/wzsA08AX3fO/T6eHYc5wj5/6vK06gAQe8sIH5jZVcBvAz/tnPvLqtOzaGb2w8CTzrkHqk5LTRwBvhf4Fefca4Fv0u5ujrmCvu1bgVcC3w4cNbN3VJuqWktdnlYdALy/ZYSZrTAu/EfOuY8Gm79sZieC/58AnqwqfQvyd4F/ZGa7jLsBf8DMhvh3HCYuABecc58J/r6LcUDw7Xj8IPAF59xTzrnngY8Cfwf/jsOssM+fujytOgB4fcsIMzPG/byPOH8CjY0AAADySURBVOf+69S/7gFOBb+fAu5edNoWyTn3Tufc9c65NcbXwB84596BZ8dhwjn3JeBxM5vc6fEW4PP4dzz2gdebWSfIK7cwHifz7TjMCvv89wC3mdmLzOyVwA3AZyP35Jyr9AG8FfhT4M+AzarTs+DP/gbGTbQHgT8OHm8FuoxH988HP49XndYFHpObgY8Hv/t8HL4H2AmujY8Bx3w8HsDPA48CDwG/AbzIp+MAfIjx+MfzjGv4PxH1+YHNoCw9B7wlbv+6FYSIiKeq7gISEZGKKACIiHhKAUBExFMKACIinlIAEBHxlAKAiIinFABERDz1/wHKcVmDdyym/gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython import display\n",
    "\n",
    "\n",
    "def recenter(cluster):\n",
    "    cluster = np.array(cluster)\n",
    "    if cluster.shape[0] <= 0:\n",
    "        return np.array([0, 0])\n",
    "    x = np.average(cluster[:,0])\n",
    "    y = np.average(cluster[:,1])\n",
    "    return np.array([x, y])\n",
    "\n",
    "colors = ['red', 'cyan', 'blue', 'green']\n",
    "color_dict = {str(index):value for index, value in enumerate(colors)}\n",
    "print(color_dict)\n",
    "\n",
    "\n",
    "def draw(_data, _clusters, centers=None, it=0,color_dict=color_dict):\n",
    "    display.clear_output(wait=True)\n",
    "    plt.xlim(0, 100)\n",
    "    plt.ylim(0, 100)\n",
    "    scatter(_data)\n",
    "    if centers is not None and len(centers) > 0:\n",
    "        for name, location in enumerate(centers):\n",
    "            plt.scatter(location[0], location[1],s=999, marker='+', color=color_dict[str(name)])\n",
    "    for _cluster, cluster_data in _clusters.items():\n",
    "        scatter(cluster_data, color=color_dict[_cluster])\n",
    "    plt.title(f'iters : {it}')\n",
    "    plt.show()\n",
    "    \n",
    "draw(data, {}, [[50, 50]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3., 3.])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "recenter([[2,2], [4,4]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "\n",
    "def k_means(_data, k, iters):\n",
    "    sample_count = _data.shape[0]\n",
    "    data_index = range(sample_count)\n",
    "    sample_index = np.random.choice(data_index, k)\n",
    "    centers = data[sample_index]\n",
    "    center_index = range(k)\n",
    "    clusters = {}\n",
    "    for it in range(iters):\n",
    "        for index in data_index:\n",
    "            sample = _data[index]\n",
    "            min_distance = sys.maxsize\n",
    "            cluster_center_index = None\n",
    "            for _index in center_index:\n",
    "                center = centers[_index]\n",
    "                _distance = distance(sample, center)\n",
    "                if _distance < min_distance:\n",
    "                    min_distance = _distance\n",
    "                    cluster_center_index = _index\n",
    "            _cluster = clusters.setdefault(str(cluster_center_index), [])\n",
    "            _cluster.append(sample)\n",
    "            draw(_data, clusters, centers, it)\n",
    "        centers = [recenter(cluster_data) for _, cluster_data in clusters.items()]\n",
    "        clusters = {}\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEICAYAAABWJCMKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/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+lWtfh48A7u45Ffv+w7ngvcHP4nkZYx8YadQug0ktGuPuGu/9l+Oe/J/hPfoDgGtwXvuw+4D2jKeHwmNks8N3ARzsOV+46AJjZq4Hbgd8AcPdX3P0lqnk9poE9ZjYNXE4wn6gy18HdHwJe6Doc9/3vAj7p7ufd/e+AJwnq2FijDgBRS0YcGFFZRsrM5oBbgC8A17r7BgRBAnjd6Eo2NL8K/DTQ7jhWxesAcB3wHPCbYUrso2a2l4pdD3d/Bvgl4MvABvCyu/8RFbsOEeK+f+b6dNQBoOeSEVVgZlcAvw/8hLt/bdTlGTYz+x7gWXd/dNRlKYlp4FuBFXe/BTjDZKc5IoW57buANwH7gb1m9gOjLVWpZa5PRx0AKr9khJldQlD5/7a7/0F4+KtmNhP+fgZ4dlTlG5J3AP/EzNYJ0oDfaWafoHrXYUsTaLr7F8LnnyIICFW7Hv8Y+Dt3f87dLwB/ANxG9a5Dt7jvn7k+HXUAqPSSEWZmBHnex9z9Vzp+dT9wd/jnu4FPD7tsw+TuP+Pus+4+R/Bv4E/c/Qeo2HXY4u5fAZ42s62VHu8AjlO96/Fl4FYzuzz8v3IHQT9Z1a5Dt7jvfz/wXjO71MzeBNwA/EXimdx9pA/g3cDjwN8CPzvq8gz5uy8QNNH+Gvir8PFu4GqC3v0nwp9XjbqsQ7wmh4DPhH+u8nX4FuBI+G/jfwH7qng9gH8P/A3wReC3gEurdB2A3yHo/7hAcIf/I0nfH/jZsC49Abyr1/m1FISISEWNOgUkIiIjogAgIlJRCgAiIhWlACAiUlEKACIiFaUAICJSUQoAIiIV9f8B1bbBgRsK1PQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "k_means(data, 4, 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# K-means++\n",
    "核心思想其实没变，只是在初始化选点的时候，把每个点的距离拉的比较开而已。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def k_means_plus(_data, k, iters, distance_threshold=5):\n",
    "    sample_count = _data.shape[0]\n",
    "    data_index = range(sample_count)\n",
    "    sample_index = np.random.choice(data_index, 1)\n",
    "    centers = data[sample_index]\n",
    "    while len(centers) < k:\n",
    "        for test_center_index in data_index:\n",
    "            match = True\n",
    "            test_point = _data[test_center_index]\n",
    "            for temp_center_index in range(len(centers)):\n",
    "                temp_center = centers[temp_center_index]\n",
    "                match = distance(temp_center, test_point) > distance_threshold\n",
    "                if not match:\n",
    "                    break\n",
    "            if match:\n",
    "                append_center = _data[test_center_index]\n",
    "                centers = np.vstack([centers, append_center])\n",
    "                break\n",
    "    center_index = range(k)\n",
    "    clusters = {}\n",
    "    for it in range(iters):\n",
    "        for index in data_index:\n",
    "            sample = _data[index]\n",
    "            min_distance = sys.maxsize\n",
    "            cluster_center_index = None\n",
    "            for _index in center_index:\n",
    "                center = centers[_index]\n",
    "                _distance = distance(sample, center)\n",
    "                if _distance < min_distance:\n",
    "                    min_distance = _distance\n",
    "                    cluster_center_index = _index\n",
    "            _cluster = clusters.setdefault(str(cluster_center_index), [])\n",
    "            _cluster.append(sample)\n",
    "            draw(_data, clusters, centers, it)\n",
    "        centers = [recenter(cluster_data) for _, cluster_data in clusters.items()]\n",
    "        clusters = {}\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEICAYAAABWJCMKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3df5Rc513f8fd3Z/1DlhpHMo5ZaeMoTiwn6/DDRIHE2Xp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wDuLucLhMbNp4DuAD3Ycrtz3AGBmrwDuAH4TwN1fdveXqOb3MQnsMLNJ4Bra64kq8z24+8PAC12Hoz7/3cDvu/tFd/8c8CTtNjZS0QEgrGTEvoKupVBmth+4DfgMcIO7r0M7SACvKu7KhuZXgZ8EWh3Hqvg9ANwEPAf8dpAS+6CZ7aRi34e7PwP8MvAFYB044+5/TsW+hxBRnz91e1p0AOhZMqIKzGwX8FHgx9z9y0Vfz7CZ2XcCz7r7Y0VfS0lMAt8ALLn7bcA5xjvNESrIbd8NvBbYC+w0s+8r9qpKLXV7WnQAqHzJCDO7gnbj/7vu/sfB4S+Z2VTw+yng2aKub0jeDvwjM1ulnQb8ZjP7Har3PWxYA9bc/TPBzx+hHRCq9n18C/A5d3/O3S8BfwzcTvW+h25Rnz91e1p0AKh0yQgzM9p53sfd/T93/OoB4J7g7/cAHxv2tQ2Tu/+Uu0+7+37a/wb+l7t/HxX7Hja4+xeBp81so9LjncBxqvd9fAF4q5ldE/y/ciftcbKqfQ/doj7/A8C7zOwqM3stcDPwl7FncvdCH8C3AyeB/wf8TNHXM+TPPku7i/Y3wF8Hj28HrqM9uv9E8Oeeoq91iN/JIeDjwd+r/D18PXAk+LfxJ8DuKn4fwL8D/hb4LPDfgauq9D0AH6Y9/nGJ9h3+D8V9fuBngrb0BPBtvc6vUhAiIhVVdApIREQKogAgIlJRCgAiIhWlACAiUlEKACIiFaUAICJSUQoAIiIV9f8B7lesPR4LXi4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "k_means_plus(data, 4, 10, 30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
